package com.ruoyi.project.cms.knowledge.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.cms.knowledge.domain.Item;
import com.ruoyi.project.cms.knowledge.service.ItemService;
import com.ruoyi.project.system.role.domain.Role;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/knowledge/item")
public class ItemController extends BaseController {

    @Autowired
    private ItemService itemService;

    String prefix = "/cms/knowledge";

    @GetMapping("")
    public String item() {
        return prefix+"/item";
    }

    @PostMapping("list")
    @ResponseBody
    public TableDataInfo list(Item item){

        startPage();


        List<Item> list = itemService.findMore(item);

        return getDataTable(list);

    }

    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

}
